#ifndef _LUA_ENGINE_H
#define _LUA_ENGINE_H

class DLL_EXPORT LuaManager : public Single<LuaManager>
{
	friend class ScriptMgr;
	template<typename T>
	void RegisterLuaClass();
	lua_State* l;
	module_* my_mod;
	void PrintStateError(int retval);
	typedef stdext::hash_map<ui32, string> CreatureHashMap;
	CreatureHashMap m_gossiphello;
	CreatureHashMap m_gossipselect;
public:
	LuaManager();
	~LuaManager();
	void Load();
	void OnGossipHello(Player* requester, Creature* sender);
	void OnGossipSelect(Player* requester, Creature* sender, ui32 intid);
	void RegisterUnitGossip(ui32 type, ui32 entry, string& funcname);
	bool HasGossipHello(Creature* sender) { return m_gossiphello.find(sender->GetEntry()) != m_gossiphello.end(); }
};

template<typename T>
void LuaManager::RegisterLuaClass()
{
	T::RegisterMyClass(module(l));
}

#endif